#include "UdpServer.hpp"
#include "Dictionary.hpp"

// ./server_udp localport
int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        cerr << "Usage: " << argv[0] << " localport" << endl;
        Die(USAGE_ERR);
    }
    // string ip = argv[1];
    uint16_t port = stoi(argv[1]);

    ENABLE_CONSOLE_LOG();

    shared_ptr<Dictionary> dic_ptr = make_shared<Dictionary>();

    unique_ptr<UdpServer> svr_ptr = make_unique<UdpServer>([&dic_ptr](const string& word){ return dic_ptr->Translate(word); }, port); 
    // func_t f = bind(&Dictionary::Translate, dic_ptr.get(), placeholders::_1)
    // unique_ptr<UdpServer> svr_ptr = make_unique<UdpServer>(f, port);
    svr_ptr->InitServer();
    svr_ptr->Start();
}